
                Index of Public Variables, Procedures and Keywords
                ====================================

program GLE2000;
 {This is primary version for updates and bug fixes
  Version GLE2000h1. Ingram   5th April 2000
  Now includes string expressions.
  subroutine calls altered to allow nesting of subroutines
  Irrecoverable error caused by zero scale factors now handled.
  Zoom cursor now installed. This uses new Resource File,
  Pointers1.Res
  Arcto, Saveas and Polar plots have been added.}
uses
  Forms,
  GLE2000E in 'GLE2000E.pas' {EditForm},
  GLE2000D in 'GLE2000D.pas' {DisplayForm},
  GLE2000T in 'GLE2000T.pas' {GLE Tools and Utilities - no form},
  GLE2000G in 'GLE2000G.pas' {GLE Graph utilities - no form},
  GLE2000F in 'GLE2000F.pas' {FillsForm},
  GLE2000P in 'GLE2000P.pas' {PrintForm},
  GLE2000W in 'GLE2000W.pas' {WindowForm};

{$R *.RES}

begin
  Application.Initialize;
  Application.Title := 'GLE2000';
  Application.HelpFile := 'Gle2000.hlp';
  Application.CreateForm(TEditForm, EditForm);
  Application.CreateForm(TDisplayForm, DisplayForm);
  Application.CreateForm(TFillsForm, FillsForm);
  Application.CreateForm(TPrintForm, PrintForm);
  Application.CreateForm(TWindowForm, WindowForm);
  Application.Run;
end.

                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

unit GLE2000E;
//////////////////////////////////////////////////////////////////////////////
//  This unit handles text processing.                                      //
//////////////////////////////////////////////////////////////////////////////
{ Edit Unit Version GLE2000H1 5th April 2000
  Input and editing of text files and primary program control
  Arc and Narc now operate on both radians & degrees
  subroutines can now be nested
  Zero scale factors now detected.
  Arto, SaveAs and polar plots added.}

interface

uses
  SysUtils, Windows, WinTypes, WinProcs, Messages, Classes, Graphics,
  Controls, Forms, Dialogs, Tabs, ExtCtrls,
  StdCtrls, Menus, GLE2000W, GLE2000T, Printers, Spin;

type
  TEditForm = class(TForm)
    SourceMenu: TMainMenu;
    F1: TMenuItem;
    Edit1: TMenuItem;
    About1: TMenuItem;
    Help1: TMenuItem;
    New1: TMenuItem;
    Open1: TMenuItem;
    Save1: TMenuItem;
    Saveas1: TMenuItem;
    Close1: TMenuItem;
    Print1: TMenuItem;
    Exit1: TMenuItem;
    Cut1: TMenuItem;
    Copy1: TMenuItem;
    Paste1: TMenuItem;
    SourceControls: TPanel;
    Label1: TLabel;
    DrawBtn: TButton;
    HideBtn: TButton;
    GraphBtn: TButton;
    EditMemo: TMemo;
    ClearBtn: TButton;
    Delete1: TMenuItem;
    SaveDialog1: TSaveDialog;
    OpenDialog1: TOpenDialog;
    PrintDialog1: TPrintDialog;
    FontDialog1: TFontDialog;
    LinePanel: TPanel;
    Label2: TLabel;
    ColPanel: TPanel;
    LineValLabel: TLabel;
    ColValLabel: TLabel;
    About: TMemo;
    C1: TMenuItem;
    Help2: TMenuItem;
    ErrorMessages1: TMenuItem;
    Conversions1: TMenuItem;
    F2: TMenuItem;
    SetFont: TMenuItem;
    Name1: TMenuItem;
    Colour1: TMenuItem;
    Height1: TMenuItem;
    Line1: TMenuItem;
    Style1: TMenuItem;
    Colour2: TMenuItem;
    Width1: TMenuItem;
    Fill1: TMenuItem;
    N1: TMenuItem;
    ColorDialog1: TColorDialog;
    transparent1: TMenuItem;
    Solid1: TMenuItem;
    Dash1: TMenuItem;
    Dot1: TMenuItem;
    Dashdot1: TMenuItem;
    Dashdotdot1: TMenuItem;
    Insideframe1: TMenuItem;
    procedure Cut1Click(Sender: TObject);
    procedure Copy1Click(Sender: TObject);
    procedure Paste1Click(Sender: TObject);
    procedure DrawBtnClick(Sender: TObject);
    procedure HideBtnClick(Sender: TObject);
    procedure GraphBtnClick(Sender: TObject);
    procedure ClearBtnClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Save1Click(Sender: TObject);
    procedure Saveas1Click(Sender: TObject);
    procedure Open1Click(Sender: TObject);
    procedure Delete1Click(Sender: TObject);
    procedure SetFontClick(Sender: TObject);
    procedure New1Click(Sender: TObject);
    procedure EditMemoEnter(Sender: TObject);
    procedure EditMemoChange(Sender: TObject);
    procedure EditMemoKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure EditMemoKeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure EditMemoMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure EditMemoMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure EditMemoClick(Sender: TObject);
    procedure Exit1Click(Sender: TObject);
    procedure Close1Click(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure About1Click(Sender: TObject);
    procedure AboutClick(Sender: TObject);
    procedure AboutDblClick(Sender: TObject);
    procedure Help2Click(Sender: TObject);
    procedure C1Click(Sender: TObject);
    procedure ErrorMessages1Click(Sender: TObject);
    procedure Conversions1Click(Sender: TObject);
    procedure Print1Click(Sender: TObject);
    procedure Name1Click(Sender: TObject);
    procedure Colour1Click(Sender: TObject);
    procedure Height1Click(Sender: TObject);
    procedure Fill1Click(Sender: TObject);
    procedure transparent1Click(Sender: TObject);
    procedure Solid1Click(Sender: TObject);
    procedure Dash1Click(Sender: TObject);
    procedure Dot1Click(Sender: TObject);
    procedure Dashdot1Click(Sender: TObject);
    procedure Dashdotdot1Click(Sender: TObject);
    procedure Insideframe1Click(Sender: TObject);
    procedure Colour2Click(Sender: TObject);
    procedure Width1Click(Sender: TObject);
  private
    Function GetStrInsertIndex : Word;
    procedure GetCursorCoord;
    { Private declarations }
  public
    Function GetLineIndex : Word;
    { Public declarations }
  end;

var
  EditForm: TEditForm;
  BmStyle,Fcol1,FCol2,FColbk:integer;  {Fill colours}
  SubStringNum,CurrentLineColor:Integer;
  FileName1:String;

Procedure DrawDiagram(FirstLine:Integer);
{Draws or redraws the current diagram}

procedure SetLineStyle(i:integer);

             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

unit GLE2000D;                                                     
{Display Unit Version GLE2000H1  5th April 2000
 Procedures for graphics display.}
interface

uses
  Windows, Messages, SysUtils,WinTypes,WinProcs, Graphics, Controls, Forms,
  Dialogs, Tabs, StdCtrls, ExtCtrls, GLE2000E, Classes, GLE2000W, GLE2000T,
  Menus, Buttons, ClipBrd, Printers;

const crZoom= 1;
      MaxTransforms= 25;

type
  TDisplayForm = class(TForm)
    DisplayPanel: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Label4: TLabel;
    TextEdit: TEdit;
    CopyButton: TButton;
    PrintButton: TButton;
    PasteButton: TButton;
    SaveButton: TButton;
    Image1: TImage;
    MainMenu1: TMainMenu;
    File1: TMenuItem;
    Line1: TMenuItem;
    Brush1: TMenuItem;
    Colour1: TMenuItem;
    Load1: TMenuItem;
    Save1: TMenuItem;
    Exit1: TMenuItem;
    Style1: TMenuItem;
    Colour2: TMenuItem;
    Width1: TMenuItem;
    Font1: TMenuItem;
    Size1: TMenuItem;
    Colour4: TMenuItem;
    EditButton: TBitBtn;
    xPanel: TPanel;
    yPanel: TPanel;
    xLabel: TLabel;
    yLabel: TLabel;
    ClearBitBtn: TBitBtn;
    PosnLabel: TLabel;
    PrintDialog1: TPrintDialog;
    Help1: TMenuItem;
    HelpContents1: TMenuItem;
    ReDrawBitBtn1: TBitBtn;
    Help2: TMenuItem;
    ErrorMessages1: TMenuItem;
    Conversions1: TMenuItem;
    FontName1: TMenuItem;
    N1: TMenuItem;
    Clear1: TMenuItem;
    Solid1: TMenuItem;
    Dash1: TMenuItem;
    Dot1: TMenuItem;
    DashDot1: TMenuItem;
    DashDotdot1: TMenuItem;
    Insideframe1: TMenuItem;
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    Panel4: TPanel;
    Window1: TMenuItem;
    Printer1: TMenuItem;
    PageSettings1: TMenuItem;
    Print1: TMenuItem;
    SaveDialog1: TSaveDialog;
    OpenDialog1: TOpenDialog;
    ModeButton: TButton;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    BitBtn4: TBitBtn;
    BitBtn5: TBitBtn;
    BitBtn6: TBitBtn;
    BitBtn7: TBitBtn;
    BitBtn8: TBitBtn;
    BitBtn9: TBitBtn;
    BitBtn10: TBitBtn;
    Reset1: TMenuItem;
    SetDefaults1: TMenuItem;
    ZoomBtn: TBitBtn;
    procedure FormCreate(Sender: TObject);
    procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure CopyButtonClick(Sender: TObject);
    procedure PrintButtonClick(Sender: TObject);
    procedure PasteButtonClick(Sender: TObject);
    procedure SaveButtonClick(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Image1DblClick(Sender: TObject);
    procedure EditButtonClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure ClearBitBtnClick(Sender: TObject);
    procedure Font1Click(Sender: TObject);
    procedure HelpContents1Click(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure ReDrawBitBtn1Click(Sender: TObject);
    procedure Help2Click(Sender: TObject);
    procedure ErrorMessages1Click(Sender: TObject);
    procedure Conversions1Click(Sender: TObject);
    procedure FontName1Click(Sender: TObject);
    procedure Size1Click(Sender: TObject);
    procedure Colour4Click(Sender: TObject);
    procedure Brush1Click(Sender: TObject);
    procedure Clear1Click(Sender: TObject);
    procedure Solid1Click(Sender: TObject);
    procedure Dash1Click(Sender: TObject);
    procedure Dot1Click(Sender: TObject);
    procedure DashDot1Click(Sender: TObject);
    procedure DashDotdot1Click(Sender: TObject);
    procedure Insideframe1Click(Sender: TObject);
    procedure Colour2Click(Sender: TObject);
    procedure Width1Click(Sender: TObject);
    procedure PageSettings1Click(Sender: TObject);
    procedure Print1Click(Sender: TObject);
    procedure Load1Click(Sender: TObject);
    procedure ModeButtonClick(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
    procedure BitBtn5Click(Sender: TObject);
    procedure BitBtn6Click(Sender: TObject);
    procedure BitBtn7Click(Sender: TObject);
    procedure BitBtn8Click(Sender: TObject);
    procedure BitBtn9Click(Sender: TObject);
    procedure BitBtn10Click(Sender: TObject);
    procedure Reset1Click(Sender: TObject);
    procedure ZoomBtnClick(Sender: TObject);
    procedure SetDefaults1Click(Sender: TObject);
    procedure FormDeactivate(Sender: TObject);
   private
    { Private declarations }
   public
  end;
  CTransform = Record {Co-ordinate Transforms}
    XOrigin,
    YOrigin,
    TranC, TranE, TranD, TranF,
    XScale, YScale,
    Rotation:double;
  end;
  SvSettings = Record  {Save & Restore Settings}
    {Dispay Settings}
    SCPnt,SLpnt:RealPoint;
    SXorgn,SYorgn,SXOffst,SYOffst,SZFactor:double;
    BgNum,Llevel,LTlevel:Integer;
    STransform,SITransform:CTransForm;
    STextangle,SArrowSize,SArrowangle:double;
    SAlinecolor,SAfillcolor,SAStyle, SSclmode:integer;
    Sastart,SAend:Boolean;
    SFont:TFont;
    SFcol,SF2col,SFbcol:TColor;
    {Pen and Brush Settings}
    SPStyle:TpenStyle;
    SPmode:TPenMode;
    SPColor:TColor;
    SPwidth:Integer;
    SBstyle:TBrushStyle;
    SBColor:TColor;
    SBitMap:TBitMap;
    SBBSet:Boolean;
  end;

  TDrawingTool = (dtNone, dtLine, dtArc, dtPaste, dtCopy, dtBox, dtSquare, dtBezier,
                  dtCircle, dtEllipse, dtMarker, dtText,dtContinue);
  TMarkerType  = (mtCircle, mtTriangle, mtSquare, mtDiamond,
                  mtDot, mtCross, mtStar, mtSnake, mtDag,
                  mtDdag, mtAsterisk, mtOplus, mtOminus,
                  mtOtimes);

var
  DisplayForm: TDisplayForm;
  BitMap,BitMap1,BrushBitMap:tbitmap;
  CurrentItem,FinalItem,ip,SpotSize,
  GLEHeight,GLEWidth,DisplayHeight,
  MarkerType,MarkerSize,
  CurrentBitBtn,LastBitBtn,gResetLevel,
  Arrowlinecolor,Arrowfillcolor,ArrowStyle, Scalemode:integer;
  PixelsPerCm,DotsPerCm,PScale,
  WindowHeight,WindowWidth,XWinOrigin,YWinOrigin,
  ArrowSize,ArrowAngle,
  XOffset,YOffset,TextAngle:double;
 { TranA,TranB,TranC,TranD,TranE,TranF,  May not Need!        {Co-ordinate transformations}
 { TranAi,TranBi,TranCi,TranDi,TranEi,TranFi:double; May Not Need! {Inverse Transformations}
  MouseMode,KeyMode,SetCurve,NewStyle,NewDrawObject,Drawing,
  NewDrawing,StartDraw,Clockwise,BrushBitmapSet,
  ArrowStart,ArrowEnd:Boolean;
  DrawStart,LastStart, DrawEnd,LastEnd,CStart,CEnd,
  ControlPoint1,ControlPoint2,TextAt :TPoint;
  DrawingTool: TDrawingTool;
  DrawingMode, LastDmode, {Controls for complex drawing operations}
  DrawingStyle,
  CTransformNum:integer;   {Level in Coordinate Transform Stack }
  ap1:array[0 .. 100] of tpoint;
  rpt1:array[0 .. 100] of RealPoint;
  CurrentTransform,CurrentInvTransform,ArrowTransform:CTransform;
  SavedSettings,ReplacedSettings,DefaultSettings:SvSettings;
  Ctrans:array [0 ..  MaxTransforms] of CTransform;
  TextOut:String;
  CurrentFont,DefaultFont,SavedFont,LastFont:TFont;
  MarkerStyle:array[ 0 ..30] of string;
  CurrentPoint,LastPoint:RealPoint;
  Mask1,Mask2:array[0 ..264] of byte;
  {Arrays used to define fill patterns  }
  FColor,F2Color,FbColor:TColor; {colours used in fill patterns.}

  function SetPenStyle(Tpen:integer):TPenStyle;
  {Sets a pen style According to The current style code}

  procedure SetBitMaps(Width,Height:integer);
  {sets size oBitmaps used for drawing }

  procedure SetBrushBitmap(BitMapStyle,NumOfBitmaps:integer;
             Var Bitmap3:TBitmap;Mask1,Mask2:array of Byte;
             FColor,F2Color,FbColor:TColor);
  { Sets up an 8 by 8 pixel bitmap using masks defined by arrays Mask1
    and Mask2 and colours defined by FColor,FColor2 and FbColor. In event
    of error a null bitmap is returned. }

  function SetBrushStyle(BrushType:integer;var BrushBitmap:TBitMap):TBrushStyle;
  {Sets a brush style According to the current style code.
   if a pattern is required the Brush Bitmap is set.}

  function  InverseTransform(CurrentTransform:CTransform):CTransform;
  {Forms the inverse of the current Transform}

  function TransformPoint(CurrentTransForm:CTransform;
                          Inpoint:RealPoint):Realpoint;
{ Converts current co-ordinate values}

  function ScreenPoint(Input:RealPoint):TPoint;
  {Derives screen coordinates for a plot point}

  function ToRealPoint(Input:Tpoint):RealPoint;
  {Derives co-ordiates in cm corresponding to a screen point
   Note, these are absolute coordinates}

  procedure DrawBezier(scale:double;x1,y1,xc1,yc1,xc2,yc2,x2,y2,
          dmode:integer);
    { Constructs a 2-Dimensional Besier spline from x1,y1 to
      x2,y2 using control points xc1,yc1 and xc2,yc2.
      Plots this on the screen using scale factor `scale' and
      mode control `dmode'.
      Set up modes 1 to 3 use narrow black lines
      dmode = 0 does nothing,
      dmode = 1 plots the straight line from start to end,
      dmode = 2 plots control points.
      dmode = 3 plots 1st control vector and curve
      dmode = 4 plots 2nd control vector and curve
      dmode = 5 plots both control vectors and curve in black.
      dmode = 6 plots curve in original style and colour.  }

    procedure DrawArc(x1,y1,xc,yc,xa,ya,dmode:integer;var x2,y2:longint;
                       var Radius,StartAngle,EndAngle:double;Clock:boolean);
   { Constructs an arc from x1,y1 to x2,y2 using control points
     xc,yc and xa,ya. xc,yc is the centre of the arc, the arc ends at
     the intersection with the line from xc,yc to xa,ya.
     The arc is drawn clockwise if Clock is TRUE.
     Plots this on the screen using mode control `dmode' as follows:
     Set up modes 1 to 3 use narrow black lines
     dmode = 0 does nothing,
     dmode = 1 plots the initial straight line from x1,y1 to xc,yc,
     dmode = 2 plots control points at x1,y1,xc,yc and xa,ya.
     dmode = 3 plots arc and 1st control vector in black.
     dmode = 4 plots arc and 2nd control vector in black.
     dmode = 6 plots arc in original style and colour.  }

procedure DrawMarker(mtype,x,y:integer;mscale:double);
{ Draws a marker of type mtype and size mscale at x,y
  Colours and fill style are set in DrawMain before calling this
  procedure }

procedure DrawArrow(Atype:integer;APoint:RealPoint;AAngle,Asize:double);
{ Draws a marker of type mtype and size mscale at x,y
  Colours and fill style are set in DrawMain before calling this
  procedure }

function IntString(I: Longint): string;
{ Converts any integer type to a string }

function RealString(R: real): string;
{ Convert any real type to a string }

procedure DisplayObject(step:integer);
{ This draws an object in final form, then sets it up in
  list of graph objects, and increments item number
  For Bezier and Arc functions Flag SetCurve is reset.  }

procedure Displayat(x,y:double;PictName:String);
{Pastes an imagefile at point x,y}

procedure CopyFrom(x,y,x1,y1:double);
{Copies the specified rectangle to the clipboard}

procedure PasteAt(x,y,x1,y1:double);
{Copies the clipboard to point x,y}

{ ************ Procedures for GLE operations ************** }

  procedure Aline(x,y:double);
  {Draws a line to x,y and makes this the current point}

 procedure Apline(r,a:double);
 {Draws a line in polar coordinates}

  procedure Amove(x,y:double);
  {Moves Current point to x,y}

 procedure Apmove(r,a:double);
 {Moves current point in polar coordinates}

  procedure ArcAt(xradius,yradius,startangle,endangle:double);
  {draws a simple arc centred at current point}

 procedure ArcTo(x1,y1,x2,y2,radius:double);
  {Fits an arc of radius r in the line segment xc,yc - x1,y1
   - x2,y2 where xc,yc is the current point.}

  procedure Bezier(xc1,yc1,xc2,yc2,xend,yend:double);
  {Draws a Bezier curve from the current point to xend,yend
   and moves current point to xend,yend }

  procedure BoxAt(x,y:double);
  {Draws a box from current point to x,y
   without resetting starting point}

  procedure Box(x,y:double);
  {Draws a box from current point to x,y
   and resets starting point}

  procedure DrawStar(Npoints,OuterRad,InnerRad,StartAngle:double);
 {Draws a star with N points, starting with first point at StartAngle.
  The star is centred on the current point with line style, line colour
  and fill style and colour defined by current settings.}

  procedure DrawRNPolygon(NumOfSides,PolyRadius,StartAngle:Double);
 {Draws an N-sided regular polygon with first corner at startangle.
  The polygon is centred on the current point and uses current lne
  and fill settings.}

  procedure SetPolygon(NumOfPoints:Integer;
             RealPolyPoint:array of RealPoint);
         {Draws a polygon in current line style and fills
          it with current fillstyle}

  procedure SetPolyLine(NumOfPoints:Integer;
             RealPolyPoint:array of RealPoint);
         {Draws a polyline in current line style}

  procedure EllipseAt(xradius,yradius:double);
  { Draws an ellipse centred at current point }

  procedure Circle(radius:double);
  {Draws a circle centred onthe current point}

  procedure Fill(Color,Style:integer);
 {Fill an area surrounding the current point using the current fill
  style and colours. Color is the boundary colour or the colour to
  be flled over.}

  procedure Marker(mktype:string;size:double);
  {Draws a marker at the curent point}

  procedure RBezier(xc1,yc1,xc2,yc2,xend,yend:double);
 {Draws a Bezier curve from the current point to xend,yend
  and moves current point to xend,yend where all parameters
  are relative to the current point  }

  procedure Rline(x,y:double);
  {Draws a line to x,y relative to present point}

 procedure RpLine(r,a:double);
 {Relative line in polar coordinates}

  procedure Rmove(x,y:double);
  {Moves Current point to x,y relative to present point}

 procedure RpMove(r,a:double);
 {Relative move in polar coordinates}

  procedure square(xx:double);
  {Draws a box centred on the current point }

  procedure Text(TextString:string;AngleOfText:Double);
  {Displays a simple Text String}

  procedure SaveSettings;
  {Saves current graph settings}

  procedure RestoreSettings;
  {Restores  last saved settings and stores current settings as Last Settings}

  procedure ResetSettings;
  {Restores last settings or default settings.}

                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

unit GLE2000G;
{ Graphs Unit. Version 3.1 31st December 1999.
  Covers operations involved in drawing a graph}
interface
uses
  Windows, SysUtils, WinTypes, WinProcs,
  Messages, Classes, Graphics, Controls, Forms, Dialogs,
  Tabs, ExtCtrls, StdCtrls, Menus, GLE2000D, GLE2000T;

const  MaxNames= 50;  

type
    {AxisTitle=record
     name:string;
     color:integer;
     hei,dist:double;
   end;    Not used   }

   DataItem=record
     DataStatus:char;
     Value:double;
   end;
   tAxis=record        {Data for linear axes or curved angle axes}
     xstart,ystart,xend,yend,  {Coordinates of end points}
     xcentre,ycentre,
     InnerRadius, OuterRadius, { Inner and out limits of axis}
     AxisStartAngle,AxisEndAngle, {used only by polar and angle axes}
     StartAt,StepBy,EndAt, {Parameters used for multiple axes}
     AxisLength,AxisAngle,    { The actual length in cms for linear axes
      or the angular length in degrees for curved axes.}
     ScaleHi,ScaleLo, {Scale limits. in case of angle axis these are in
      degrees or radians. Basic axis measures always in degrees.}
     {For angular axes tick postions etc are in degrees or radians.}
     TickStart,SubTickStart,MidTickStart,        {First tick positions}
     dTicks,dSubTicks,dMidTicks,                 {Tick spacings}
     TickLength,SubTickLength,MidTickLength,
     TickLineWidth,SubTickLineWidth,MidTickLineWidth,
     TickAngle,
     GridStart,SubGridStart,MidGridStart,        {Grid Starting Points}
     dGrid,dSubGrid,dMidGrid,         {Grid spacings}
     GridLength,MidGridLength,SubGridLength,
     GridLineWidth,SubGridLineWidth,MidGridLineWidth,
     GridAngle,TitleAngle,
     NameDist,NameShift,NameAngle, {Name shift in degs/rads for angle axes}
     AxisLineWidth,
     MidLabelShift,MidLabelDist,  {Label shift in degs/rads for angle axes}
     LabelShift,LabelDist,LabelAngle,
     TitleHei,MidLabelHei,LabelHei,NameHei,      {Text heights in cm}
     TitleShift,TitleDist:double;  {Title position, both in cms}

     nTicks,nSubTicks,nMidTicks,                 {Number of ticks}
     nGrids,nSubGrids,nMidGrids,                 {Number of Grid lines}
     AxisType,                                   {Axis Type}
     TickColor,SubTickColor,MidTickColor,        {Tick colours}
     GridColor,SubGridcolor,MidGridColor,        {Grid colours}
     AxisColor,NameColor,
     NumOfNames,NumOfPlaces,                     {Size of arrays}
     MidLabelSFigs,MidLabelDFigs,
     LabelSFigs,LabelDFigs,
     TitleColor,MidLabelColor,LabelColor:integer; {Title colours}
     TickStyle,SubTickStyle,MidTickStyle,        {Tick styles}
     GridStyle,SubGridStyle,MidGridStyle,        {Grid and tick line styles}
     AxisLineStyle:TPenStyle;
     Title,TitleFontName,LabelFontName,MidLabelFontName,NameFontName:string;
     AxisLabels,ANames:array[0 ..MaxNames] of string;
     ShowName,ShowPlace,ShowMidPlace:array[0 .. 50] of boolean;
     AxisOff,SideOn,Negate,PolarAxis,AngleAxis,                        {Flags}
     NoFirst,NoLast,LabelsOn,MidLabelsOn,
     GridOn,TicksOn,MidTicksOn,SubTicksOn,
     SymmetricTicks,SymmetricMidticks,SymmetricSubticks,
     MidGridOn,SubGridOn,NamesOn:Boolean;
   end; {tAxis}

   gdata=record
     name:string;
     dcol:array[0 ..99] of Byte;
   end;

   plotset=record
     xaxis,yaxis,zaxis, {defines either x1axis or x2axis etc.}
     xcol,ycol,NumOfPoints,                  {would be safe to use raxis and aaxis as well}
     mborder,mlcolor,mfcolor,msNumber,
     pcolor,pstyle,smoothvalue:integer;
     errwidth,errup,errdown,
     herrwidth,herrleft,herrright,
     pwidth,msize:double;
     mstyle:string;
     markeron,lineon,erron,
     smooth:boolean;
   end;

   PlotTransform=record
     gtype:integer;
     gta,gtb,gtc,     {Plot to paper coordinate transform }
     gtd,gte,gtf:double;
     xIsLog,yIsLog:Boolean;
   end;

   pdata= array[0 .. 99] of plotset;
   Datacol=array[ 0 .. 250] of DataItem;
   DataSet=array [0 .. 99] of DataCol;

var  gxsize,gysize,             {Graph Dimensions}
     gstartx,gstarty,           {Start point for graph box}
     gxoffset,gyoffset,         {Offset of graph origin }
     GTitleDist,GTitleOffset,   {Graph Title Position}
     gxorigin,gyorigin,         {Graph Origin}
     hscale,vscale,             {Axis scale factors}
     DataAtX,DataAtY,           {Position of data display}
     GTitleHei:double;          {Title Height}
     GTitleColor,
     DataColNum,NumOfDataCols,  {Data Column settings}
     CurrentDstart,CurrentDEnd,
     LastDStart,LastDEnd,
     DataRowNum,NumOfDataRows,
     DColStart,DColEnd,DColstep,
     DRowStart,DRowEnd,DRowStep:integer;   {Range of data display}
     x1axis,x2axis,y1axis,y2axis,z1axis,z2axis,r1axis,r2axis,
     r3axis,r4axis,CurrentAxis:tAxis;
     a1Axis,a2Axis:tAxis;
   {  UseX1Axis,UseX2Axis,UseY1Axis,UseY2Axis,  }
     NoBox,FullSize,DataDefined,ShowPlotData:Boolean;
     GTitle,GTitleFontName,
     DataSetName:string;             {Graph Title}
     Linc:array[0..19] of double;
     CurrentPenStyle:TPenStyle;
     CurrentBrushStyle:TBrushStyle;
     DataCol1:dataCol;
     Data:DataSet;
     PlotIsOn:array[0 .. 99] of Boolean;
     PlotData:pdata;       {The array of plotting data sets }
     CurrentPlot:plotset;  {The current set of plot data}
     GraphTransform,ScaleTransform:PlotTransform;

 procedure AutoScale(DataHi,DataLo:double;VAR ScaleHi,
                   ScaleLo:double;VAR NumOfSeg,ScaleType:integer);
{ Takes as input upper and lower data limits DataHi,DataLo and scale type
  ScaleType ( 1 for linear, 2 for log, 3 for probability scale ).
  Resets ScaleType if necessary and returns suitable upper and lower
  scale limits ScaleHi,ScaleLo. NumOfSeg is no. of segments in a linear scale
  or no. of decades*100 in a log. scale   }

  procedure DrawAxis(var Axis:tAxis);
  { Draws a linear or logarithmic axis specified by:
    ScaleLo - lower value of axis range
    ScaleHi - upper limit of axis range
    xstart,ystart - co-ordinates of start of axis
    xend,yend     - co-ordinates of end of axis,
    dStart - first point for ticks,
    dTicks - distance between ticks
    dSubStart,dSubticks - same for subticks
    dMidStart,dMidTicks - same for middle ticks
    TickAngle - Angle of ticks relative to axis
    Mark1Leng,Mark2Leng,Mark3Leng - scale marker lengths
    LogStyle - Submark style for a log axis
    AxisType - axis type: 1 = linear, 2 = logarithmic
     3 = probability,  4 = sinh,  9 = Linear polar scale,
     10 = log polar scale, 11 = prob polar scale,
     12 = sinh polar scale, 17 = linear polar angle }

procedure DrawAngleAxis(var AngAxis:TAxis);
{Draws an angular axis}

procedure SetAxisDefaults;
{Resets all axis parameters to default values}

procedure SetAngleAxisDefaults;
{Resets all angle axis parameters to their default values}

procedure BSpline(StepSize:double;Fit,NumOfCpts:integer;
                 PlotLeft,PlotRight,PlotLo,PlotHi:double;
                  Cpoint:array of RealPoint);
  {Draws a B-spline curve starting from Cpoint[0] and ending at
   CPoint[NumOfPts]. The intermediate points in the array Cpoint
   serve as control points. The parameter StepSize sets the size
   of the steps between each control point. (e.g. StepSize = 0.05
   sets 20 steps between contro points.) Fit is a parameter which
   selects the fitting strategy. Fit = 0 uses a basic B-spline
   algorithm with end points not fixed. Fit = 1 forces the curve to
   start at Cpoint[0] and end at Cpoint[NumOfCpts]. Increasing Fit
   up to 10 forces closer fitting to the straight lines through the
   control points. Fit between 11 and 20 forces curve through the
   control points. Fit betqween 21 and 30 does the same using a
   different algorithm. The curve is drawn using the current pen
   color, style etc. and using the current coordinate transform
   settings.}

procedure PlotToPaper(xd,yd:double;CurrentGraphTransform:PlotTransform; var xp,yp:double);
{Converts plotter data co-ordinates xd,yd to paper co-ordinates
 xp,yp using the conversion parameters gca,gcb,gcc,gcd,gce,gcf,
 xIsLog,yIslog from the current data transform. }

function ClipMode(xy, lo, hi:double):integer;
{ Determines location of value relative to clipping limits}

 procedure SetPlotDefaults(PlotNumber:integer);
{Resets  a plot data record to default settings }

procedure SetUpGraph;
{At the start of a graph block this procedure
 performs initialisation operations for the graph}

procedure SetUpPolar;
{At the start of a Polar plot block this procedure
 performs initialisation operations for the plot}

procedure SetGraphTransform(xaxis,yaxis:integer;var CurrentGraphTransform:PlotTransform;
             xofs,yofs:double);
 {sets up Transform parameters for Graph to Paper
  xaxis & yaxis define axes used.}


procedure ConstructGraph;
{At end f a graphics block this procedure uses the
 input to the block to construct the graph and plot
 the data.}

procedure ConstructPolarGraph;

Procedure InsertPlots(PlotHi,PlotLo,PlotLeft,PlotRight:double;
                       PolarPlot:Boolean);
        {Insets plots as set up in constructGraph or ConstructpolarGraph}

 procedure Inputdata(var Colnum:integer;DataSetName:string);
{Organises input of data to DataSet Data}

{function FileExists(FileName: string): Boolean;
{ Boolean function that returns True if the file exists; otherwise,
  it returns False. Closes the file if it exists. }

 procedure CheckData(xs,ys:double;Rstart,Rend,Rstep,Cstart,Cend,Cstep:integer);
 { Display of a section of the data array
  Locate top left at point x,y.  Display from Rstart to Rend in steps of
  Rstep. From Cstart to Cend in steps of Cstep  }

              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

unit GLE2000F;
{ Fills Unit  Sets up fill colours and patterns
  D. Ingram Version 3.1 31st December 1999}
interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Spin, ExtCtrls;

type
  TFillsForm = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Panel1: TPanel;
    Panel2: TPanel;
    SpinEdit1: TSpinEdit;
    Label1: TLabel;
    Button7: TButton;
    Button8: TButton;
    Panel3: TPanel;
    Panel4: TPanel;
    Panel5: TPanel;
    Panel6: TPanel;
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure SpinEdit1Change(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FillsForm: TFillsForm;
  Action,ln:integer;

           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

unit GLE2000P;
{ Print Unit  Version 3.1  31st December 1999
  Controls printer output. Tested with H.P. Deskjet and
  Cannon BJC-240 Printers }
interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, Spin,GLE2000T;

type
  TPrintForm = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    SpinButton1: TSpinButton;
    SpinButton2: TSpinButton;
    Label4: TLabel;
    Label5: TLabel;
    Edit3: TEdit;
    SpinButton3: TSpinButton;
    Panel1: TPanel;
    Button1: TButton;
    Button2: TButton;
    CheckBox1: TCheckBox;
    Label6: TLabel;
    procedure SpinButton1DownClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpinButton1UpClick(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
    procedure SpinButton2DownClick(Sender: TObject);
    procedure SpinButton2UpClick(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
    procedure SpinButton3DownClick(Sender: TObject);
    procedure SpinButton3UpClick(Sender: TObject);
    procedure Edit3Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  PrintForm: TPrintForm;
  TopMargin,LeftMargin,ImageScale:double;
  PrintFullPage:Boolean;

           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

unit GLE2000W;
{ Window Control Unit for GLE2000.
  Version 1.001  D. Ingram.  31st December 1999.}

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, Spin, GLE2000T;

type
  TWindowForm = class(TForm)
    Label1: TLabel;  {Origin}
    Label4: TLabel;  {Size}
    Label2: TLabel;  {x cm origin}
    Edit1: TEdit;    {NewXorg edit}
    SpinButton1: TSpinButton;
    Label3: TLabel;  {y cm origin}
    Edit2: TEdit;
    SpinButton2: TSpinButton;
    Label5: TLabel;   {x cm size}
    Edit3: TEdit;
    SpinButton3: TSpinButton;
    Panel1: TPanel;   {Lower line}
    Button1: TButton; {Accept}
    Button2: TButton; {Cancel}
    Label6: TLabel;    {y cm size}
    Edit4: TEdit;
    SpinButton4: TSpinButton;    { x zoom factor}
    Edit5: TEdit;
    SpinButton5: TSpinButton;
    Label9: TLabel;    {Zoom Factor}
    Panel2: TPanel;    {Zoom Button is represented by a panel}
    Button3: TButton;  {Resets Zoom  to 1.0}
    Button4: TButton;  {Sets to default values}
    Button5: TButton;  {Restores previous settings}
    procedure FormCreate(Sender: TObject);
    procedure SpinButton1DownClick(Sender: TObject);
    procedure SpinButton1UpClick(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
    procedure SpinButton2DownClick(Sender: TObject);
    procedure SpinButton2UpClick(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
    procedure SpinButton3UpClick(Sender: TObject);
    procedure SpinButton3DownClick(Sender: TObject);
    procedure Edit3Change(Sender: TObject);
    procedure SpinButton4UpClick(Sender: TObject);
    procedure SpinButton4DownClick(Sender: TObject);
    procedure Edit4Change(Sender: TObject);
    procedure SpinButton5UpClick(Sender: TObject);
    procedure SpinButton5DownClick(Sender: TObject);
    procedure Edit5Change(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  WindowForm: TWindowForm;

               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

unit GLE2000T;
{Utilities for GLE2000
 Version GLE2000H1 D. Ingram 5th April 2000
  Includes string expessions. Function codes now numeric.
  Log, log10 and ^ now protected against overflow.}
interface

uses
   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics,
   Controls,Forms, Dialogs, Tabs, ExtCtrls, {Style1, MrkStyle,}
   StdCtrls, Menus,{Symbols,} Spin, Buttons;

const
    Degree=57.2957795130823208767;
    DegToRad=1.0/Degree;  {only used in Graph - circa line 357}
    Exp1=  2.7182818284590452353;
    Gamma=  0.5772156649015328606;
    LogE=   0.4342944819032518277;
    MaxBegins= 100;                     //Size of Begin Stack
    MaxForLoops= 25;
    MaxRepeats=  25;
    MaxWhiles=   25;
    MaxIfs=      20;
    Maxsubs=     20;
    NumOfMarkers=30;
    NumOfcolors= 44;
    NumOfFills = 40;
    NumOfStrings=100;                  {Number of substrings in a line }
    CurveDef=100;                      {Number of point defining a curve}
    Pi =     3.1415926535897932384;
    TwoPi = 2.0*Pi;
    AngleMeasure:double=Degree;          { Set to Degree if in degrees or }
    SigFigs:integer=6;                { to 1.0 if in Radians }
    DecFigs:integer=3;
  {colour constants}
    Black      = $00000000;
    White      = $00FFFFFF;
    DarkRed    = $000000CE;
    Red        = $000000FF;
    LightRed   = $00A0A0FF;
    DarkGreen  = $00077000;
    Green      = $00009900;
    LightGreen = $0000CE00;
    DarkBlue   = $00800000;
    Blue       = $00FF0000;
    LightBlue  = $00FEFAA8;
    DarkBrown  = $000060A8;
    Brown      = $000090E0;
    LightBrown = $0070C0FF;
    Yellow     = $0000FFFF;
    DarkGrey   = $00505050;
    Grey       = $00808080;
    Silver     = $00C0C0C0;
    LightGrey  = $00E0E0E0;
    MistGrey   = $00F0F0F0;
    Maroon     = $00000080;
    Olive      = $00008080;
    Purple     = $00A000A0;
    Fuschia    = $00FF00FF;
    Lime       = $0000FF00;
    Aqua       = $00FFFF00;
    Primrose   = $00CAFFFF;
    Parchment  = $00E0FFFF;
    Gold       = $0017BAFF;
    OffWhite   = $00F8F8F8;
    Lavender   = $00FFF0F8;
    BlueTint   = $00FFFFF0;
    GreenTint  = $00E6FFE6;
    Pink       = $00CDCDFF;

type Mrkrs= Array[0 .. NumOfMarkers] of String;
     clrs = Array[0 .. NumOfColors]  of String;
     fls= Array[0 .. NumOfFills] of String;

     RealPoint = Record
       x:double;
       y:double;
     end;

     ForLoopData = Record
       ForVariable:String;
       StartLine:integer;
       StartValue,EndValue,StepValue:double;
     end;

     IfRecord = Record
       SkipOn,DoneIf:Boolean;
     end;

     sub = Record    {Used to set array Subroutine[] - see below}
      subName:String;
      substart,subreturn,LastSubNumber,NumOfSubPars:integer;
      subValue:double;
      subSet:Boolean;
      subParname: array[0 .. 25] of string;
      subPartype: array[0 .. 25] of integer;
      subParvalue: array[0 .. 25] of double;
     end;

const
   Markers:mrkrs=('circle','triangle','square','diamond','fcircle',
                  'ftriangle','fsquare','fdiamond','dot','cross',
                  'club','heart','star','snake','dag',
                  'ddag','asterisk','oplus','ominus','otimes',
                  'odot','trianglez','squarez','diamondz','wcircle',
                  'wtriangle','wsquare','wdiamond','sqdot','dmddot',
                  'plus');
   colors:clrs = ('black','white','darkred','red','lightred',
                 'darkgreen','green','lightgreen','darkblue','blue',
                 'lightblue','darkbrown','brown','lightbrown','yellow',
                 'darkgrey','grey','silver','lightgrey','mistgrey',
                 'maroon','olive','purple','fuschia','lime',
                 'aqua','primrose','parchment','gold','offwhite',
                 'lavender','bluetint','greentint','pink','clear',
                 'colr0','colr1','colr2','colr3','colr4',
                 'colr5','colr6','colr7','colr8','clr9');
 ColorTitles:clrs = ('Black','White','Darkred','Red','Lightred',
                 'Darkgreen','Green','Lightgreen','Darkblue','Blue',
                 'Lightblue','Darkbrown','Brown','Lightbrown','Yellow',
                 'Darkgrey','Midgrey','Grey','Silver','Lightgrey',
                 'Maroon','Olive','Purple','Fuschia','Lime',
                 'Aqua','Primrose','Parchment','Gold','Offwhite',
                 'Lavender','Bluetint','Greentint','Pink','Clear',
                 'colr0','colr1','colr2','colr3','colr4',
                 'colr5','colr6','colr7','colr8','clr9');
   fills:fls   = ('clear','solid','rightdiagonal','leftdiagonal','squares',
                  'diamonds','horizontals','verticals','fineverticals',
                  'verticalbars',
                  'thickverticalbars','finehorizontals','horizontalbars',
                  'thickhorizontalbars','finesquares',
                  'thicksquares','largesquares','hollowsquares',
                  'thickhollowsquares','finesquaremesh',
                  'squaremesh','solidcircles','hollowcircles',
                  'fineleftdiagonals','leftdiagonalbars',
                  'thickleftdiagonalbars','finerightdiagonals',
                  'rightdiagonalbars','thickrightdiagonalbars',
                  'finediamondmesh',
                  'thickdiamondmesh','smalldiamonds','bigdiamonds',
                  'diagonalweave','verticalweave',
                  'horizontalzigzag','thickhorizontalzigzag','verticalzigzag',
                  'thickverticalzigzag','horizontaltriangles',
                  'verticaltriangles');
 FillTitle:fls = ('Clear','Solid','Right diagonal','Left diagonal','Squares',
                  'Diamonds','Horizontals','Verticals','Fine verticals',
                  'Vertical Bars',
                  'Thick Vertical Bars','Fine Horizontals','Horizontal Bars',
                  'Thick Horizontal Bars','Fine Squares',
                  'Thick Squares','Large Squares','Hollow Squares',
                  'Thick Hollow Squares','Fine Square Mesh',
                  'Square Mesh','Solid Circles','Hollow Circles',
                  'Fine Left Diagonals','Left Diagonal Bars',
                  'Thick Left Diagonal Bars','Fine Right Diagonals',
                  'Right Diagonal Bars','Thick Right Diagonal Bars',
                  'Fine Diamond Mesh',
                  'Thick Diamond Mesh','Small Diamonds','Big Diamonds',
                  'Diagonal Weave','Vertical Weave',
                  'Horizontal Zigzag','Thick Horizontal Zigzag',
                  'Vertical Zigzag','Thick Vertical Zigzag',
                  'Horizontal Triangles',
                  'Vertical Triangles');


 var
  out1,out2,out3:string;
  SetAxis,SetAngleAxis,SetGraph,SetPolar,SetGraphic,SetKey,{Used in line parsing}
  SetData,SkipLine,LastSkip,SubSkipOn,
  SetLineStyle,   {could be in implimentation}
  SetPlot,SetPlotStyle,{Set plot flags data input, SetPlotStyle flags plot style}
  AxisSet,KeySet,Diagnostics,Disaster,Halt,Inaccurate,
  ExpressionIsString,UpdateSettings:Boolean;
  {Used in line parsing}
  BeginNum,BeginValue,      {Level & Value in Begin stack }
  ForLoopNum,ForLoopValue,  {ditto for   ForLoop}
  FirstLine,  {Start of actual diagram}
  CurrentSubNumber, {Global variable used in Unit GLE2000E}
  IfLevel:Integer;          {Level in IF Stack}
  StringIndex,LastIndex,LocalLevel,LocalTextlevel,subnumber:integer;
  NewXorg,NewYorg,NewXsize,NewYsize,zoomfactor,
  SpA,SpB,SpC,SpE,SpF,SpG,  {Parameters for Screen point conversions}
  InitZoom, InitXOrg, InitYOrg, InitXsize, InitYsize:double; {Window settings}
  WidthOfText:double;
  StringType,LastType:Array[0 .. NumOfStrings] of integer;
  StringText,LastText:Array[0 .. NumOfStrings] of string;
  StringValue,LastValue:Array[0 .. NumOfStrings] of double;
  Getcolor: array[0 .. 50] of integer;
  ForLoopStack:array[0 .. MaxForLoops] of ForLoopData;
  RepeatStack:array[0 ..MaxRepeats] of integer; {Only need to record start line}
  WhileStack:array[0 .. MaxWhiles] of integer; { ditto }
  IfStatus:array[0 .. MaxIfs] of IfRecord;
  {Stack used to check begin/end matchings}
  BeginStack: array[ 0 .. MaxBegins] of integer;
  subroutine: array[0 .. MaxSubs] of sub;
  vv:array[0 .. 275] of double;  {used for global variables }
  vw:array[0 .. 390] of double;  {used for local variables }
  vwt:array[0 .. 101] of string;

   Function Atan2(x,y:double):double;
   {Returns arctangent for full range 0 to 2Pi}

   Function Sign(x:double):integer;
   {Sign of a real number}

   Function Isign(x:integer):integer;
   {Sign of an integer number}

   Function RPoint(x,y:double):RealPoint;
   {Sets value of a real point to x,y}

   Procedure MatMult (a,b,c,d:double;var Ta,Tb,Tc,Td:double);
   {Premultiplies 2x2 matrix Ta,tb,tc<td by matrix a,b,c d
    and returns result as in place of original matrix}

   Procedure SetVariableValue(Vs:String; var vl:double; var Vtext:String);
   {Sets the variable Vs to Value vl
    This version modified for use in GLE95.}

   function  Expression(SExp:String;Var ReturnedString:String;
     Var StringReturned:Boolean;Var Ecode,Ecode1,Ecode2:Integer):double;
   {Attempts to evalate the value of a string repesentation of an expression }

   Procedure ResetPars(Rst:integer);
  {Resets parameters
     Rst = 2 Resets Angle and Output number Format
     Rst = 1 Resets Other parameters
     Rst = 3 Resets everything.}

   procedure RemoveQuotes(Var ss:string);
   {Removes Quotes from a simpleString}

   Procedure Analyse(s1:string;var StringNum:integer);
  {Analyses a string into its constituent components and attempts to
   express each component as a command, variable, function, etc.}

   Function GetLine(Var LineNum:Integer):String;
  { This starts at line number LineNum and attempts to construct
   a compound line by adding continuation lines and skipping
   comment lines. If successful the result is returned as the
   function. Non catastrophic failures allow optional continuation.
   Catastrophic failures also set the Global Flag 'Disaster'.
   Various error messages may be returned.}

        ===========================================

  implementation
   uses GLE2000E,GLE2000G,GLE2000D;   { Watch this!}

  const
    DrawLine=
    '!-----------------------------------------------------------------------';
    MaxLineCount  =  10;
    NumOfAxisPars = 64;
    NumOfCmds     = 26;
    NumOfConst    =  12;
 {   NumOfDataOps  =  4;    }
    NumOfFns      = 64;
    NumOfGraphics = 74;
    NumOfGraphs   = 24;
    NumOfpolars   = 28;
    NumOfGPars    = 22;
    NumOfPlotpars = 42;
    NumOfKeys     = 10;
    NumOfBgns     = 30;
    NumOfBoxes    =  3;
    NumOfJusts    = 11;
    NumOfLines    =  4;
 {   NumOfMisc    =   3;   }
    NumOfSetngs   = 37;
    Quit          =  3;
    Radian        =  1.0;    { Only used once - circa line 2866}
  type
    cmds     = Array[0 .. NumOfCmds]     of String;
    constnts = Array[0 .. NumOfConst]    of String;
    fns      = Array[0 .. NumOfFns]      of String;
    grphcs   = Array[0 .. NumofGraphics] of String;
    grphs    = Array[0 .. NumOfGraphs]   of String;
    plrs     = Array[0 .. NumOfPolars]   of string;
    grphprs  = Array[0 .. NumOfGPars]    of String;
    kys      = Array[0 .. NumOfKeys]     of String;
    bgn      = Array[0 .. NumOfBgns]     of String;
    bxs      = Array[0 .. NumOfBoxes]    of String;
    jst      = Array[0 .. NumOfJusts]    of String;
    lns      = Array[0 .. NumOfLines]    of String;
    pltpars  = Array[0 .. NumOfPlotpars] of String;
    stngs    = Array[0 .. NumOfSetngs]   of String;
    Symbols  = Set of Char;
    Stops    = Set of char;
    xpars    = array[0 .. NumOfAxisPars] of String;
  const
   Graphics:grphcs=('aline','amove','arc','arcto','begin',
               'bezier','bigfile','box','circle','closepath',
               'curve','define','dfont','ellipse','pixelspercm',
               'end','windoworigin','apolyline','rpolyline','fill',
               'fillto','fillover','xgsave','xgrestore','xgreset', //gsave etc.
               'x4x','include','input','join','let',              //deactivated
               'marker','move','narc','newpath','displayat',
               'piechart','apolygon','rpolygon','rbezier','print',
               'region','pasteat','reverse','rline','rmove',
               'saveas','set','size','square','dotspercm',
               'text','textwidth','use','copyfrom','write',
               'xaxis','x2axis','yaxis','y2axis','zaxis',
               'z2axis','fopen','fclose','apline','apmove',
               'rpline','rpmove','raxis','r2axis','r3axis',
               'r4axis','aaxis','a2axis','star','rnpolygon');

    Graphs:grphs=('bar','data','end','fill','fullsize',
               'hscale','setkey','textwidth','nobox','size',
               'title','vscale','xaxis','x2axis','yaxis',
               'y2axis','zaxis','z2axis','showdataat','fromrow',
               'torow','steprowby','fromcol','tocol','stepcolby');

    Polars:plrs=('xxxxxx','data','end','fill','fullsize',
                 'hscale','setkey','textwidth','nobox','size',
                 'title','vscale','raxis','r2axis','r3axis',
                 'r4axis','aaxis','a2axis','showdataat','fromrow',
                 'torow','steprowby','fromcol','tocol','stepcolby',
                 'xinnerradiusx','xouterradiusx','xendatangle',
                 'centrecircle');

    {There should be no common graph (or polar) and axis parameters}
    AxisPars:xpars=('color','font','format','hei','length',
               'linewidth','linecolor','linestyle','dticks','dsubticks',
               'dmidticks','dgrid','dsubgrid','dmidgrid','tickstart',
               'subtickstart','midtickstart','gridstart','subgridstart',
                        'midgridstart',
               'nticks','nmidticks','nsubticks','ngrids','nmidgrids',
               'nsubgrids','max','min','dist','side',
               'ticks','midticks','subticks','grid','midgrid',
               'subgrid','angle','title','log','linear',
               'negate','nofirst','nolast','on','off',
               'labels','midlabels','names','places','start',
               'end','shift','offset','midplaces','prob',
               'float','fix','symmetric','normal','polar',
               'startatangle','stepangleby','endatangle',
                       'innerradius','outerradius');
    {There should be no common graph and plot parameters}
    PlotPars:pltpars=('autoscale','line','marker','err','errwidth',
                      'errup','errdown','from','herr','herrwidth',
                      'herrleft','herrright','key','linestyle','linewidth',
                      'linecolor','border','size','XmkrlinecolorX','fillcolor',
                      'nomiss','smooth','smoothm','xmin','xmax',
                      'ymin','ymax','xaxis','x2axis','yaxis',
                      'y2axis','zaxis','z2axis','r1axis','r2axis',
                      'r3axis','r4axis','a1axis','a2axis','use',
                      'xiscol','on','off');
    {these parameters may be same as axis and plot parameters   }
    GraphPars:grphprs=('linestyle','linewidth','color','xxxx','xxxx',
                        'xxxx','pos','hei','offset','from',
                        'xtox','xstepx','font','dist','on',
                        'grid','log','min','max','dpoints',
                        'length','xxxxx','xxxxx');

      DataOps:symbols=['*','+','-','/','<','>','^','_','|'];

   keys:kys=('offset','position','text','linestyle','marker',
             'msize','mscale','color','hei','fill',
             'nobox');

   Beginnings:bgn=('origin','rotate','scale','translate','graph',
                   'polarplot','smithchart','local','box','clip',
                   'key','path','table','text','fill',
                   'add','name','stroke','width','xaxis',
                   'x2axis','yaxis','y2axis','zaxis','z2axis',
                   'raxis','r2axis','r3axis','r4axis','aaxis','a2axis');
   { use codes  25 on for FOr loop, REPEAT, WHILE, and IF structures}
   Boxes:bxs=('fill','justify','nobox','name');

   JustTo:jst=('left','centre','right','tl','tc','tr',
        'lc','cc','rc','bl','bc','rc');

   Lines:lns=('arrow','start','end','both','none');

   Settings:stngs=('cap','but','round','square','fontcolor',
      'dashlen','fillstyle','fillcolor','font','fontlinewidth',
      'hei','join','mitre','round','bevel',
      'just','linewidth','linestyle','linecolor','arrowstyle',
      'arrowlinecolor','arrowfillcolor','arrowsize','roman','froman',
      'wroman','greek','fgreek','wgreek','norman',
      'fnorman','wnorman','saxon','fsaxon','wsaxon',
      'fill2color','fillbcolor','color');
  {MathPad commands used for evaluating expressions }
   MPComs:cmds=('now','settings','=','diagnostics','clear',
                'degrees','radians','fix','float','x1x',
                'for','to','step','next','repeat',
                'until','while','endwhile','goto','return',
                'if','elseif','else','endif','sub',
                'endsub','halt');
  {MP functions}
    MPfns:fns=('now$(','abdate(','date$(','left$(',
      'right$(','seg$(','num$(','cut$(','chr$(',       { '1' to '9'}
      'abs(','atn(','cos(','exp(','floor(','int(','len(',
      'log(','log10(','not(','pos(','rnd(','sgn(','sin(',
      'sqr(','sqrt(','tan(','val(','acos(','asin(','atn2(',
      'cosh(','sinh(','tanh(','acosh(','asinh(',        {'A' to 'Z'}
      'atanh(','erf(','erfc(','si(','ci(','gamma(',
      'lgamma(','fact(','bjn(','bkn(','bin(','byn(',
      'bico(','frc(','frs(','round(','setcol(','xxx','time$(','cdate$(',
      'insert$(','twidth(','theight(','xg(','yg(','xxx',   {'a' to 'z'}
      'rg(','ag(','xxxx','xxxx');
  {MP variables}
    Letters:Symbols=['a','b','c','d','e','f','g','h','i','j','k',
    'l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','$'];
  {Standard terminators}
    Stop1:Symbols=[' ',';'];
  {Extended terminators}
    Stop2:Symbols=[' ',',',';','('];
    Stop3:Symbols=[',',';',')'];
  {Maths operators}
    MathOps:Symbols=['+','-','~','*','/','^'];
    LogOps:Symbols=['>','<','=','|','&'{,'?','?','''}];
    Digits:Symbols=['0','1','2','3','4','5','6','7','8','9'];
    HexDigits:Symbols=['0','1','2','3','4','5','6','7','8','9',
                       'a','b','c','d','e','f'];
    AddOps:Symbols=['+','-'];
    Constants:constnts=('pie','rad','deg','exp','loge',
                        'ln10','ntodb','xx1','xx2','yx1',
                        'yx2','zx1','zx2');
    var
      i,j,k,l,m,n,ii,LastCommandNumber,kommand,VariableEnd,
      StartStringAt,EndStringAt,Laststart,Linepos,StringLength,
      code,code1,code2,codea,codeb,codec,Fval,SetVariable,
      ErrorNumber:integer;
      a,b,c,d,e,f,g,h,o,p,q,r,s,t,u,v,w,x,y,z,vb,VarValue:double;
      s2,s3,s4,LastVariable:string;
      ValueSet,AssignVariable,CommaFound,ShStrings,lstructure,
      emessage,enumber:Boolean;
      MPad:TextFile;
    {UsedinMaths Fns}
      glntop: longint;
      gla: ARRAY [1..33] OF double;
      glna: ARRAY [1..100] OF double;

